package com.buddies.lottery.ui.lottery;

import com.buddies.lottery.base.BasePresenter;
import com.buddies.lottery.data.BaseObserver;
import com.buddies.lottery.data.DataManager;
import com.buddies.lottery.data.bean.Lottery;
import com.buddies.lottery.data.result.PageResult;

/**
 * Created by xuliang on 2018/2/28.
 */

public class LotteryCategoryPresenter extends BasePresenter<LotteryCategoryContract.View> implements LotteryCategoryContract.Presenter {

    public LotteryCategoryPresenter(LotteryCategoryContract.View view) {
        super(view);
    }

    @Override
    public void loadLotteryList(int lotteryCategoryId) {
        addSubscription(DataManager.getInstance().getLotteryRepo().getLotteryList(lotteryCategoryId), new BaseObserver<PageResult<Lottery>>() {
            @Override
            public void onNext(PageResult<Lottery> response) {
                mView.onLotteryListLoaded(response);
            }

            @Override
            public void onError(Throwable e) {
                mView.onError(e);
            }
        });
    }

}
